//
//  BaseTextView.swift
//  OnemeetingDemo
//
//  Created by 张衡 on 2019/12/6.
//  Copyright © 2019 www.onemeeting.1meetingIos. All rights reserved.
//

import Foundation

class BaseTextView: NSView {
    
    override init(frame frameRect: NSRect) {
        super.init(frame: frameRect)
        setupUI()
    }
    
    required init?(coder decoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setupUI() {
        self.addSubview(scrolleView)
        scrolleView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
        
        
        scrolleView.documentView = txView
        txView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
    
    lazy var scrolleView: NSScrollView = {
        let view = NSScrollView.init(frame: CGRect.zero)
        view.hasVerticalRuler = true
        view.hasHorizontalRuler = true
        return view
    }()
    
    lazy var txView: NSTextView = {
        let view = NSTextView()
        view.minSize = NSMakeSize(0, 100)
        view.maxSize = NSMakeSize(CGFloat(Float.greatestFiniteMagnitude), CGFloat(Float.greatestFiniteMagnitude))
        view.isEditable = false
        view.isVerticallyResizable = true
        view.isHorizontallyResizable = false
        view.backgroundColor = NSColor.white
        view.string = ""
        view.font = NSFont.systemFont(ofSize: 12)
        view.textColor = NSColor.black
        view.textContainer?.containerSize = NSMakeSize(CGFloat(Float.greatestFiniteMagnitude), CGFloat(Float.greatestFiniteMagnitude))
        view.textContainer?.widthTracksTextView = true
        return view
    }()
    
    
}
